package module{
	
	import component.Image;
	
	import flash.display.Sprite;
	
	import utils.Tween;
	
	public class LoginPanel extends Sprite{
		
		public static var instance:LoginPanel = new LoginPanel();
		
		public function LoginPanel(){
			var bg:Image = addChild(new Image()) as Image;
			bg.load("resource/LoginBg.png",function():void{
				x = Global.stage.stageWidth + bg.width;
				y = (Global.stage.stageHeight - height)>>1;
			});
		}
		
		public override function set visible(value:Boolean):void{
			openEffect(value);
		}
		
		private function openEffect(isOpen:Boolean):void{
			var oX:int = this.x;
			if(isOpen){
				var targert:Sprite = this;
				var dX1:int = (Global.stage.stageWidth - width) - 40;
				var dX2:int = (Global.stage.stageWidth - width) -20;
				Tween.to(targert,600,{x:[oX,dX1]},function():void{
					var oX1:int = targert.x;
					Tween.to(targert,150,{x:[oX1,dX2]});
				});
			}else{
				Tween.to(this,700,{x:[oX,Global.stage.stageWidth + width]});
			}
		}
		
		public function onResize():void{
			this.x = (Global.stage.stageWidth - width) -20;
			this.y = (Global.stage.stageHeight - height)>>1;
		}
		
	}
}